

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>快照计划模块 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="CephFS 快照镜像" href="../cephfs-mirroring/" />
    <link rel="prev" title="CephFS Top 工具" href="../cephfs-top/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">快照计划模块</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/snap-schedule.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id4">管理</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../createfs/"> 创建 CephFS 文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../administration/"> 管理命令</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multifs/"> 创建多个文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-remove-mds/"> 配备、增加、删除 MDS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/">术语</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds">MDS 守护进程的引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#id3">故障切换的管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#standby-replay">热备（ standby-replay ）的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-join-fs">配置 MDS 与文件系统的亲和性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cache-configuration/"> MDS 缓存配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-config-ref/"> MDS 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-mds/"> ceph-mds 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nfs/"> 通过 NFS 导出</a></li>
<li class="toctree-l3"><a class="reference internal" href="../app-best-practices/"> 应用最佳实践</a></li>
<li class="toctree-l3"><a class="reference internal" href="../fs-volumes/"> FS 卷和子卷</a></li>
<li class="toctree-l3"><a class="reference internal" href="../quota/"> CephFS 配额管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../health-messages/"> 健康消息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/">升级 MDS 集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/#firefly-jewel">升级比 Firefly 老的文件系统，需过 Jewel 这个槛</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-top/"> CephFS Top 工具</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 定时快照</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id2">如何启用</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">用法</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-mirroring/"> CephFS 快照镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="../purge-queue/"> 清理队列</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="snap-schedule">
<span id="id1"></span><h1>快照计划模块<a class="headerlink" href="#snap-schedule" title="Permalink to this heading"></a></h1>
<p>该模块为 CephFS 实现了按计划做快照。它提供了一个用户界面，可以添加、查询和删除快照计划和保留策略，还提供了一个调度程序，用于拍下快照并相应修剪现有快照。</p>
<section id="id2">
<h2>如何启用<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p><em>snap_schedule</em> 模块可以这样启用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mgr</span> <span class="n">module</span> <span class="n">enable</span> <span class="n">snap_schedule</span>
</pre></div>
</div>
</section>
<section id="id3">
<h2>用法<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>此模块用到 <a class="reference internal" href="../../dev/cephfs-snapshots/"><span class="doc">CephFS 快照</span></a> ，最好也读一下这篇文档。</p>
<p>此模块的子命令位于 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">fs</span> <span class="pre">snap-schedule</span></code> 命名空间下。
参数可以是位置参数或关键字参数。一旦遇到关键字参数，
后面的所有参数也会被认为是关键字参数。</p>
<p>快照计划由路径、重复时间间隔和开始时间确定。
重复间隔定义了两个连续快照之间的时间间隔。
它由一个数字和一个周期乘数指定，是 <cite>h(our)</cite> 、 <cite>d(ay)</cite> 、
<cite>w(eek)</cite> 、 <cite>M(onth)</cite> 和 <cite>y(ear)</cite> 中的一个。
例如， <cite>12h</cite> 的重复间隔表示每 12 小时拍一次快照。
开始时间是一个时间字符串
（下文将详细介绍传递时间）。
默认情况下，开始时间是前一天半夜。
因此，如果在 13:50 添加重复间隔为 <cite>1h</cite> 的快照计划，
并采用默认开始时间，那么第一个快照将在 14:00 拍下。
如果字符串里没有明确指定时区，那就假定时区是 UTC 。
明确指定的时区将在执行时映射成 UTC 时间。
开始时间必须按 ISO8601 格式。示例如下：</p>
<ul class="simple">
<li><p>UTC：2022-08-08T05:30:00 即上午 5:30 UTC ，没指定时区偏移</p></li>
<li><p>IDT：2022-08-08T09:00:00+03:00 即上午 6:00 UTC</p></li>
<li><p>EDT：2022-08-08T05:30:00-04:00 即上午 9:30 UTC</p></li>
</ul>
<p>保留规范由路径和保留规范本身标识。
保留规范由一个数字和一个时间段组成，
中间用空格隔开，或者由 <cite>&lt;数字&gt;&lt;时间段&gt;</cite> 对拼接而成。
其含义是，该规范将确保保留至少相隔 <cite>&lt;时间段&gt;</cite> 的 <cite>&lt;数字&gt;</cite> 个快照。
例如， <cite>7d</cite> 表示用户希望保留 7 个快照，
这些快照之间至少相隔一天（也可能更长）。
支持的时间段有： <cite>h(our)</cite> 、 <cite>d(ay)</cite> 、 <cite>w(eek)</cite> 、 <cite>M(onth)</cite> 、
<cite>y(ear)</cite> 和 <cite>n</cite> ，最后一个是个特殊的修饰符，
例如 <cite>10n</cite> 意思是保留最后 10 个快照，而不是按时间算、</p>
<p>所有子命令都接受可选的 <cite>fs</cite> 参数，用于指定多文件系统配置和 <a class="reference internal" href="../fs-volumes/"><span class="doc">FS 卷和子卷</span></a> 管理配置中的路径。
如果没有传递 <cite>fs</cite> 参数，则默认使用 fs_map 中列出的第一个文件系统。
使用 <a class="reference internal" href="../fs-volumes/"><span class="doc">FS 卷和子卷</span></a> 时，参数 <cite>fs</cite> 等同于 <cite>volume</cite> 。</p>
<p>当传入时间戳时（ <cite>add</cite> 、 <cite>remove</cite> 、 <cite>activate</cite> 和 <cite>deactivate</cite> 子命令中的 <cite>start</cite> 参数），
ISO 格式 <cite>%Y-%m-%dT%H:%M:%S</cite> 最通用。
如果用的是 python3.7 或更高版本，
或安装了 <a class="reference external" href="https://github.com/movermeyer/backports.datetime_fromisoformat">https://github.com/movermeyer/backports.datetime_fromisoformat</a> ，
则任何能被 python 的 <cite>datetime.fromisoformat</cite> 解析的有效 ISO 时间戳都是可以用的。</p>
<p>没有提供子命令时，将打印出命令提纲：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#&gt; ceph fs snap-schedule</span>
<span class="n">no</span> <span class="n">valid</span> <span class="n">command</span> <span class="n">found</span><span class="p">;</span> <span class="mi">8</span> <span class="n">closest</span> <span class="n">matches</span><span class="p">:</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">status</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="nb">format</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="nb">list</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">--</span><span class="n">recursive</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="nb">format</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">add</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">snap_schedule</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">start</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">remove</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">repeat</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">start</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">add</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">retention_spec_or_period</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">retention_count</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">remove</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">retention_spec_or_period</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">retention_count</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">activate</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">repeat</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">start</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">deactivate</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">repeat</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">start</span><span class="o">&gt;</span><span class="p">]</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">Error</span> <span class="n">EINVAL</span><span class="p">:</span> <span class="n">invalid</span> <span class="n">command</span>
</pre></div>
</div>
<section id="id4">
<h3>注意<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h3>
<p>此命令不再支持 <cite>subvolume</cite> 参数。</p>
<section id="id5">
<h4>查验快照计划<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h4>
<p>此模块有两个子命令来检查当前的计划表： <cite>list</cite> 和 <cite>status</cite> 。
用可选的 <cite>format</cite> 参数选择纯文本或 json 格式的输出，
默认为纯文本。<cite>list</cite> 子命令会以简短的单行格式列出路径上的所有计划表。
它提供了一个 <cite>recursive</cite> （递归）参数，
可以列出指定目录和及其包含目录中的所有计划表。
<cite>status</cite> 子命令会打印一个路径的所有可用计划表和保留规格。</p>
<p>实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">status</span> <span class="o">/</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">status</span> <span class="o">/</span><span class="n">foo</span><span class="o">/</span><span class="n">bar</span> <span class="o">--</span><span class="nb">format</span><span class="o">=</span><span class="n">json</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="nb">list</span> <span class="o">/</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="nb">list</span> <span class="o">/</span> <span class="o">--</span><span class="n">recursive</span><span class="o">=</span><span class="n">true</span> <span class="c1"># list all schedules in the tree</span>
</pre></div>
</div>
</section>
<section id="id6">
<h4>增加或删除计划<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h4>
<p><cite>add</cite> 和 <cite>remove</cite> 子命令分别用于添加和删除快照计划。二者都需要至少一个 <cite>path</cite> 参数， <cite>add</cite> 还需要一个 <cite>schedule</cite> 参数，如 USAGE 章节所述。</p>
<p>一个路径可以添加多个不同的计划表。
如果两个计划表的重复时间间隔和开始时间不同，则认为它们彼此不同。</p>
<p>如果在路径上设置了多个计划表，指定精确的重复间隔和开始时间后，
<cite>remove</cite> 可以删除一个路径的单个计划，或者在只指定 <cite>path</cite> （路径）时，
这个子命令会删除此路径的所有计划。</p>
<p>实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">add</span> <span class="o">/</span> <span class="mi">1</span><span class="n">h</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">add</span> <span class="o">/</span> <span class="mi">1</span><span class="n">h</span> <span class="mi">11</span><span class="p">:</span><span class="mi">55</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">add</span> <span class="o">/</span> <span class="mi">2</span><span class="n">h</span> <span class="mi">11</span><span class="p">:</span><span class="mi">55</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">remove</span> <span class="o">/</span> <span class="mi">1</span><span class="n">h</span> <span class="mi">11</span><span class="p">:</span><span class="mi">55</span> <span class="c1"># removes one single schedule</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">remove</span> <span class="o">/</span> <span class="mi">1</span><span class="n">h</span> <span class="c1"># removes all schedules with --repeat=1h</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">remove</span> <span class="o">/</span> <span class="c1"># removes all schedules on path /</span>
</pre></div>
</div>
</section>
<section id="id7">
<h4>增加或删除保留策略<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h4>
<p><cite>retention add</cite> 和 <cite>retention remove</cite> 子命令允许管理保留策略。
一个路径只有一个保留策略，
但一个策略可以包含多个计时对，以便指定复杂的保留策略。
可以通过 <cite>ceph fs snap-schedule retention add &lt;path&gt; &lt;time period&gt; &lt;count&gt;</cite>
和 <cite>ceph fs snap-schedule retention add &lt;path&gt; &lt;countTime period&gt;[countTime period]</cite>
单独地或批量地添加、删除保留策略。</p>
<p>实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">add</span> <span class="o">/</span> <span class="n">h</span> <span class="mi">24</span> <span class="c1"># keep 24 snapshots at least an hour apart</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">add</span> <span class="o">/</span> <span class="n">d</span> <span class="mi">7</span> <span class="c1"># and 7 snapshots at least a day apart</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">remove</span> <span class="o">/</span> <span class="n">h</span> <span class="mi">24</span> <span class="c1"># remove retention for 24 hourlies</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">add</span> <span class="o">/</span> <span class="mi">24</span><span class="n">h4w</span> <span class="c1"># add 24 hourly and 4 weekly to retention</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">retention</span> <span class="n">remove</span> <span class="o">/</span> <span class="mi">7</span><span class="n">d4w</span> <span class="c1"># remove 7 daily and 4 weekly, leaves 24 hourly</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>向 snap-schedule 添加路径时，记住去掉挂载点的路径前缀。
给 snap-schedule 指定的路径应该是从相应的 CephFS 文件系统根目录开始，
而不是从客户端主机的文件系统根目录开始。例如，
假设 Ceph 文件系统挂载在 <code class="docutils literal notranslate"><span class="pre">/mnt</span></code> ，而需要拍快照的路径是 <code class="docutils literal notranslate"><span class="pre">/mnt/some/path</span></code> ，
那么 snap-schedule 所需的实际路径就只有 <code class="docutils literal notranslate"><span class="pre">/some/path</span></code> 。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>需要注意的是， snap-schedule status 命令输出中的“ created ”字段是创建计划时的时间戳。
created 时间戳与实际快照的创建无关。
实际快照创建情况在 created_count 字段中说明，
该字段是迄今为止创建的快照总数的累积计数。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>每个目录保留快照的最大数量由配置选项
<cite>mds_max_snaps_per_dir</cite> 限制，其默认值为 100 。
为确保能创建新快照，将保留比该数量少一个的快照。
因此，默认情况下最多保留 99 个快照。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果有多个文件系统，还得加上 --fs 参数。</p>
</div>
</section>
<section id="id8">
<h4>有效和无效的计划<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h4>
<p>可以为目录树中还不存在的路径添加快照计划。
同样，删除路径也不会影响该路径的快照计划。
如果按计划拍快照时目录不存在，
此计划将被设置为无效（ inactive ），
并将被排除在计划调度之外，直到再次激活为止。
可以手动把计划设置为无效，以暂停按计划创建快照。
本模块为此功能提供了 <cite>activate</cite> （激活）和 <cite>deactivate</cite> （停用）子命令。</p>
<p>实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">activate</span> <span class="o">/</span> <span class="c1"># activate all schedules on the root directory</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="n">snap</span><span class="o">-</span><span class="n">schedule</span> <span class="n">deactivate</span> <span class="o">/</span> <span class="mi">1</span><span class="n">d</span> <span class="c1"># deactivates daily snapshots on the root directory</span>
</pre></div>
</div>
</section>
<section id="id9">
<h4>局限性<a class="headerlink" href="#id9" title="Permalink to this heading"></a></h4>
<p>快照使用 python Timer （计时器）进行调度。
在正常情况下，指定 1h 的计划会让拍快照相当精确地间隔 1 小时。
但是，如果 mgr 守护进程负载过重，定时器线程可能无法立即调度，
导致快照稍有延迟。如果出现这种情况，
下一个快照仍将照旧，就像前一个快照没延迟过一样，
即一个或多个延迟的快照不会导致计划表的整体偏移。</p>
<p>如果在卷上快照计划处于活动状态时删除了卷，那么在这些卷上执行命令时，
可能会在日志文件或命令行中看到 Python Tracebacks （回溯）。
虽然我们已采取措施考虑 fs_map 的变化、并删除活跃的计时器、
关闭数据库连接，以避免 Python 回溯，但由于问题的固有性质，不可能完全消除回溯。
在出现此类回溯的情况下，要使系统达到稳定状态，
唯一的解决办法就是禁用并重新启用 snap_schedule 管理器模块。</p>
<p>为了在一定程度上限制文件系统中快照的总体数量，
该模块只为每个目录保留最多 50 个快照。
如果保留策略想要保留的快照超过 50 个，保留列表将缩短成最新的 50 个快照。</p>
</section>
<section id="id10">
<h4>数据存储<a class="headerlink" href="#id10" title="Permalink to this heading"></a></h4>
<p>快照计划数据存储在 cephfs 元数据存储池里的一个 rados 对象中。运行时，
所有数据都放在一个 sqlite 数据库中；存储时，就被序列化成一个 rados 对象。</p>
</section>
</section>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../cephfs-top/" class="btn btn-neutral float-left" title="CephFS Top 工具" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../cephfs-mirroring/" class="btn btn-neutral float-right" title="CephFS 快照镜像" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>